#include <stdio.h>

int main()
{
    #if 1
        /*for循环*/
        int count = 3;
        for (size_t i = 0; i < count; i++)
        {
            /* code */
            printf("hello world!\n");
        }
        /*请你计算1-4999的偶数的和*/
        int sum = 0;
        for (int idx = 1; idx < 5000; idx++)
        {
            /*如何知道一个数是偶数*/
            if (idx % 2 == 0)
            {
                sum = sum + idx;
            }
        }
        printf("sum = %d\n", sum);
    #endif

    #if 1
        /*while循环*/
        /*千万不要死循环*/
        int cnt = 5;
        while (cnt)
        {
            /* code */
            printf("welcome to 271class!\n");
            cnt -= 1;
        }
        int count = 1;
        while (count <= 100)
        {
            printf("%d\t", count);
            if (count % 3 == 0)
            {
                printf("\n");
            }
            count += 1;
        }

    #endif

    #if 1
        /*
        前置：先运算后判断
        后置：先判断后运算
        */
        int cnt = 3;
        while (--cnt)
        {
            printf("666\n");
        }

        return 0;
        /*1-100打印3的倍数 当3的个数超过7的时候，就结束*/
        cnt = 0;
        for (int idx = 1; idx < 100; idx++)
        {
            if (idx % 3 != 0)
            {
                continue;
            }
            else
            {
                printf("idx = %d\n", idx);
                cnt++;

                if (cnt > = 7)
                {
                    /*退出循环*/
                    break;
                }
            }
        }

    /*仙花数，121 123321 */
    // 12-10000里面所有仙数的个数
    int fireCnt = 0;
    for (int idx = 12; idx <= 10000; idx++)
    {
        /*只需要判断每一个idx是不是仙数*/
        int recordIdx = idx;

        int reverseIdx = 0;
        /*取出idx逆序的数*/
        while (recordIdx)
        {
            int remain = recordIdx % 10;
            recordIdx = recordIdx / 10;
            reverseIdx = reverseIdx * 10 + remain;
        }
        if (idx == reverseIdx)
        {
            // printf("idx = %d\n", idx);
            fireCnt++;
        }
    }
    printf("fireCent = %d\n", fireCnt);




    /*do...while*/
    int flag = 0;
    do
    {
        /* code */
        printf("777\n");
    } 
    while (flag );
}
